package com.tangfuzhong.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class HWInvocationHandler implements InvocationHandler {

    private Object target;

    private MyInterceptor myInterceptor;

    public HWInvocationHandler() {
    }

    public HWInvocationHandler(Object target,MyInterceptor myInterceptor) {
        this.target = target;
        this.myInterceptor = myInterceptor;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        MyInvocation myInvocation = new MyInvocation(target,method,args);
        return myInterceptor.intercept(myInvocation);
    }


}
